package com.around.test.m3u8;

import cn.hutool.core.io.FileUtil;
import com.around.test.m3u8.util.AesUtils;
import com.around.test.m3u8.util.HttpsUtil;
import org.apache.commons.codec.binary.Hex;

import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class ParseTsFilePyPath {
    public static void main(String[] args) throws Exception {
       /* byte[] iv= Hex.decodeHex("bce374fa1bc863e9a8225eccd09dc162");
        File file=new File("E:\\电子书\\12_4_19.ts");
        byte[] key = FileUtil.readBytes("C:\\Users\\moodincode\\Downloads\\v1 (3)");
        InputStream inputStream1 = new HttpsUtil().httpsGet("https://www.jiakao520.com/oss/decrypt?CipherText=ZGNkMWI2ZWYtNGM5NC00MzZmLWE1MjAtYjQ4Y2VmYTAwOTM2dndHMXF5UnNXSjZ6bzd1VGJzYVRwVVdqanppQllrYVBBQUFBQUFBQUFBQlFMZmY3QUUxaGQyN2RFRmJGaU95TmU0N0VseTZDZmlCUGJLNHo4empVdjRXNzlGdFREb3Y2&MtsHlsUriToken=TnNXa1phaW5NKjJeUiZtMk9qRG9jbDRITlVESlE2eTJZZzJIVkpqc01sVzJaMmgtWi1XVTNOMlJrWTJObE5qVXlaVEk5VFhOVWEyTmhkMjVOS2tSZVl5WjVNazVxUkc5cmJIbElUbFZxU2pBMk1ESk5aM3BJWTBwNWMwMXNlakpSTW5rdFVDMVVTVEpPUkdNNVRXcFpNRTFVTUhjTzBPME8=",2 );
        FileUtil.writeFromStream(inputStream1,"C:\\Users\\moodincode\\Downloads\\v1 (4)");
        key=FileUtil.readBytes("C:\\Users\\moodincode\\Downloads\\v1 (4)");
        InputStream inputStream = AesUtils.decryptCBC(new FileInputStream(file), key, iv);
        FileUtil.writeFromStream(inputStream,"E:\\电子书\\12_4_000333.ts");*/
        //String text = "60 network range 19.122.149.1 19.122.150.254";
        String text = "0 network host address 173.231.184.119";
        // (?<ip>\d[1-3].\d[1-3].\d[1-3].\d[1-3])$
       // System.out.println(String.join("-",text.split("\\s")));
       /*String key= "ddd2as[33332]";
        String[] strings = key.split("[\\[|\\]]");
        System.out.println(String.join(",",strings)+"  "+strings.length);*/
        Pattern pattern = Pattern.compile("^(?<id>\\d+) network host address (?<ip>\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3})$");
        Matcher matcher = pattern.matcher(text);

        while (matcher.find()) {
            /*if (matcher.group(1) != null) {
                String value = matcher.group(1);
                System.out.println(value);
            } else if (matcher.group(2) != null) {
                String value = matcher.group(2);
                System.out.println(value);
            }*/
            for (int i = 0; i <= matcher.groupCount(); i++) {
                System.out.println(matcher.group(i));
            }
        }
    }
}
